﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EFong.View.Proxy;
using UIShare;

namespace EFong.View.Documentation
{
    public partial class Frm_ReturnJourneyOrder : BasicForm
    {
        private Contract.JourneyOrder oldInsurancePolicy = null;
        public Contract.JourneyOrder NewInsurancePolicy = null;

        private MasterServiceProxy _masterServiceProxy;

        public Frm_ReturnJourneyOrder(Contract.JourneyOrder oldInsurancePolicy)
        {
            InitializeComponent();
            this.oldInsurancePolicy = oldInsurancePolicy;
        }

        protected override void LoadDatas()
        {
            this.txt_OldRef.Text = oldInsurancePolicy.Passenger;
        }

        protected override void InitFields()
        {
            this._masterServiceProxy = MasterServiceProxy.GetInstance();
        }

        public bool Result { get; set; }

        protected override void Events()
        {
            this.btn_Confirm.Click += (s, e) =>
            {
                var result = _masterServiceProxy.ReturnJourneyOrder(oldInsurancePolicy, this.txt_NewRef.GetText());
                if (result.IsSuccess) 
                {
                    Result = true;
                    //MsgBox.Info("寄回成功");
                    this.Close();
                }
            };

            this.btn_Cancel.Click += (s, e) =>
            {
                Result = false;
                this.Close();
            };
        }
    }
}
